<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<canvas id="drawing" width="200" height="200">A drawing of something.</canvas>
<script>
    
    /*
        canvas的功能看P553
     */
    
    let drawing = document.getElementById('drawing')
    // 确保浏览器支持
    if (drawing.getContext) {
        let context = drawing.getContext('2d');
        console.log(context)
        
        let imgURL = drawing.toDataURL('image/png')
        let image = document.createElement('img')
        image.src = imgURL
        document.body.appendChild(image)
    }

</script>
</body>
</html>